package com.etlmaster.datax.plugins.tranformer;

import java.util.HashMap;
import java.util.Map;

import com.dp.nebula.wormhole.common.interfaces.ILine;
import com.dp.nebula.wormhole.common.interfaces.IParam;
import com.etlmaster.executor.utils.DpExecutorUtils;

@ComponentAnnotation("addField")
public class TransFieldAdd  extends LineTransProcessor{

	private String value;
	private String paramName;
	private Map<String,String> map;
	public TransFieldAdd(Integer fieldIndex, String changeCode,
			String paramStr, IParam param) {
		super(fieldIndex, changeCode, paramStr, param);
		map=new HashMap<String,String>();
		String fileName=param.getValue(paramName);
		map.put("fileName", fileName);
	}

	@Override
	public void transField(ILine line,IParam param) {
		
		String AddFiled=DpExecutorUtils.variableSubstitution(value, map);
		line.addField(AddFiled);
	}

	@Override
	public boolean isSkip() {
		// TODO Auto-generated method stub
		return false;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getParamName() {
		return paramName;
	}

	public void setParamName(String paramName) {
		this.paramName = paramName;
	}

}
